package com.cloud.bc.service.impl;

import com.cloud.bc.model.entity.BcPaymenways;
import com.cloud.bc.mapper.BcPaymenwaysMapper;
import com.cloud.bc.service.BcPaymenwaysService;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;

import java.math.BigInteger;
import java.util.List;

/**
 * 支付配置
 *
 * @author douhaichao code generator
 * @date 2021-03-22 16:34:34
 */
@Service
@AllArgsConstructor
public class BcPaymenwaysServiceImpl extends ServiceImpl<BcPaymenwaysMapper, BcPaymenways> implements BcPaymenwaysService {

    /**
   * 根据对象属性查找满足条件的第一条数据     *      * @return
   */
    @Override
    public BcPaymenways selectOne(BcPaymenways req) {
        QueryWrapper queryWrapper = new QueryWrapper<BcPaymenways>();
        queryWrapper.setEntity(req);
        return baseMapper.selectOne(queryWrapper);
    }

    /**
     * 根据条件查询所有
     */
    @Override
    public List<BcPaymenways> selectAll(BcPaymenways req) {
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.setEntity(req);
        return baseMapper.selectList(queryWrapper);
    }

    /**
     * 根据对象查询所有分页数据(精确查询)     *      * @return
     */
    @Override
    public IPage<BcPaymenways> selectPage(Page page, BcPaymenways req) {
        IPage<BcPaymenways> list = baseMapper.selectPage(
                page,
                new QueryWrapper<BcPaymenways>().setEntity(req));
        return list;
    }

    /**
     * 根据对象查询所有分页数据(模糊查询)     *      * @return
     */
    @Override
    public IPage<BcPaymenways> selectPageByLike(Page page, BcPaymenways req) {
        QueryWrapper queryWrapper = new QueryWrapper();
        
                                        if (null !=req.getId()) {
                    queryWrapper.eq("id" , req.getId());
                }
                    
                            if (!StrUtil.isEmpty(req.getAlias())) {
                    queryWrapper.like("alias" , req.getAlias());
                }
                                
                            if (!StrUtil.isEmpty(req.getName())) {
                    queryWrapper.like("name" , req.getName());
                }
                                
                            if (!StrUtil.isEmpty(req.getScene())) {
                    queryWrapper.like("scene" , req.getScene());
                }
                                
                            if (!StrUtil.isEmpty(req.getIcon())) {
                    queryWrapper.like("icon" , req.getIcon());
                }
                                
                            if (!StrUtil.isEmpty(req.getIntroduction())) {
                    queryWrapper.like("introduction" , req.getIntroduction());
                }
                                
                            if (!StrUtil.isEmpty(req.getNote())) {
                    queryWrapper.like("note" , req.getNote());
                }
                                
                            if (!StrUtil.isEmpty(req.getConfig())) {
                    queryWrapper.like("config" , req.getConfig());
                }
                                
                            if (!StrUtil.isEmpty(req.getFormdata())) {
                    queryWrapper.like("formdata" , req.getFormdata());
                }
                                
                                        if (null !=req.getIsSwitch()) {
                    queryWrapper.eq("is_switch" , req.getIsSwitch());
                }
                    
                                        if (null !=req.getSort()) {
                    queryWrapper.eq("sort" , req.getSort());
                }
                            IPage<BcPaymenways> list = baseMapper.selectPage(page, queryWrapper);
        return list;
    }

    /**
     * 根据条件统计数据量     *      * @return
     */
    @Override
    public int count(BcPaymenways req) {
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.setEntity(req);
        return baseMapper.selectCount(queryWrapper);
    }
}
